<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!--dashboard calendar-->
<link href="${ctxPath}/static/css/clndr.css" rel="stylesheet">
<!--Morris Chart CSS -->
<link rel="stylesheet"
	href="${ctxPath}/static/js/morris-chart/morris.css">
<!--common-->
<link href="${ctxPath}/static/css/style.css" rel="stylesheet">
<link href="${ctxPath}/static/css/style-responsive.css" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon"
	href="${ctxPath}/static/images/lukk.ico" media="screen" />
<link rel="icon" href="${ctxPath}/static/images/lukk.ico"
	type="image/x-icon" />
<link rel="bookmark" href="${ctxPath}/static/images/lukk.ico"
	type="image/x-icon" />

<link rel="stylesheet" type="text/css"
	href="${ctxPath}/static/js/bootstrap-timepicker/css/timepicker.css" />
<link rel="stylesheet" type="text/css"
	href="${ctxPath}/static/js/bootstrap-datetimepicker/css/datetimepicker-custom.css" />

<title>导航页</title>
<section>
	<!-- 右上角 -->
	<div class="header-section">
		<a class="toggle-btn"><i class="fa fa-bars"></i></a>
		<div class="menu-right">
			<p></p>
			<ul class="notification-menu">
				<li><strong style="color: red">请勿在管理页面开启的时候，浏览其他网站。 </strong></li>
				<li>欢迎 <font color="blue"><strong>
							${sessionScope.sessionUser.workerCode} </strong></font>登录! &nbsp; <span
					class="label label-success" data-toggle="modal"
					data-target="#logoutModel">注销</span>&nbsp;&nbsp;&nbsp;<!-- <span
					class="label label-success" data-toggle="modal"
					data-target="#myModal">修改登陆密码</span> --></li>
			</ul>
		</div>
	</div>
	<!-- 右上角结束 -->
	<div class="left-side sticky-left-side">
		<div class="left-side-inner">
			<!--左侧菜单栏-->
			<ul class="nav nav-pills nav-stacked custom-nav">
				<li id="welcome" class=""><a href="${ctxPath}/index.html"><i
						class="fa fa-home"></i><span>欢迎页</span></a></li>
				<c:choose>
					<c:when test="${not empty menuList}">
						<c:forEach var="parent_menu" items="${sessionScope.menuList }">
							<c:if test="${parent_menu.hasResource == true}">
								<li class="menu-list" id="${parent_menu.code}"><a href=""><i
										class="fa fa-book"></i> <span>${parent_menu.name}</span></a> <c:forEach
										var="child_menu" items="${parent_menu.children}">
										<c:if test="${child_menu.hasResource == true}">
											<ul class="sub-menu-list" style="display: none;">
												<li id="${child_menu.code}"><a
													href="${ctxPath}/${child_menu.url}">${child_menu.name}</a></li>
											</ul>
										</c:if>
									</c:forEach></li>
							</c:if>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<h2>
							&nbsp;&nbsp;&nbsp;没有数据，<br /> &nbsp;&nbsp;&nbsp;因为你没有权限
						</h2>
						<h2>
							&nbsp;&nbsp;&nbsp;伤心不，<br /> &nbsp;&nbsp;&nbsp;因为你没有数据
						</h2>
					</c:otherwise>
				</c:choose>
			</ul>
			<!--sidebar nav end-->
		</div>
	</div>
</section>
<!-- 模态框修改密码暂时关闭（Modal） -->
<%-- <div class="modal fade" style="top: 200px;" id="myModal" tabindex="-1"
	role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-hidden="true">&times;</button>
				<h4 class="modal-title">更改密码</h4>
			</div>
			<div class="modal-body">
				<form class="form-horizontal" id="modifyForm" role="form">
					<input type="hidden" name="id"
						value="${sessionScope.sessionUser.id}">
					<div class="form-group">
						<label for="firstname" class="col-sm-2 control-label">登录账号</label>
						<div class="col-sm-10">
							<input type="text" readonly="readonly" class="form-control"
								value="${sessionScope.sessionUser.workerCode}">
						</div>
					</div>
					<div class="form-group">
						<label for="lastname" class="col-sm-2 control-label">登录密码</label>
						<div class="col-sm-10">
							<input type="password" class="form-control" id="iworkerPassword"
								name="password" placeholder="密码">
						</div>
					</div>
					<div class="form-group">
						<label for="lastname" class="col-sm-2 control-label">再次输入</label>
						<div class="col-sm-10">
							<input type="password" class="form-control" id="rePutPassword"
								placeholder="再次输入密码">
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
				<button type="button" onclick="modifyInternalWorker()"
					id="submitModifyFormButton" disabled="disabled"
					class="btn btn-primary">提交更改</button>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal -->
</div> --%>


<!-- 注销模态框（Modal） -->
<div class="modal fade" style="top: 200px;" id="logoutModel"
	tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
	aria-hidden="true">
	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-body">
				<h2>
					<strong>您确认退出吗？</strong>
				</h2>
				<br /> <br />
			</div>
			<div class="modal-footer">
				<button type="button" class="btn btn-default" data-dismiss="modal">关闭
				</button>
				<button type="button" onclick="logoutIntenalWorker()"
					class="btn btn-default">确认</button>
			</div>
		</div>
		<!-- /.modal-content -->
	</div>
	<!-- /.modal -->
</div>
<script src="${ctxPath}/static/js/jquery-1.10.2.min.js"></script>
<script src="${ctxPath}/static/js/jquery-ui-1.9.2.custom.min.js"></script>
<script src="${ctxPath}/static/js/jquery-migrate-1.2.1.min.js"></script>
<script src="${ctxPath}/static/js/bootstrap.min.js"></script>
<link href="${ctxPath}/static/css/bootstrap.min.css" rel="stylesheet" />
<script src="${ctxPath}/static/js/modernizr.min.js"></script>
<script src="${ctxPath}/static/js/jquery.nicescroll.js"></script>
<script src="${ctxPath}/static/js/scripts.js"></script>
<script src="${ctxPath}/static/js/html5shiv.js"></script>
<script src="${ctxPath}/static/js/respond.min.js"></script>

<!-- toastr提示框的使用 -->
<script src="${ctxPath}/static/js/useful-toastr/toastr.min.js"></script>
<link href="${ctxPath}/static/js/useful-toastr/toastr.min.css"
	rel="stylesheet" />
<script src="${ctxPath}/static/js/useful-ewin/Ewin.js"></script>

<script>
	function indexmenu(oneMenu, twoMenu) {
		$("#" + twoMenu).attr("class", "active");
		var sub = $("#" + oneMenu).find('>ul'); //原来是查ul
		visibleSubMenuClose();
		$("#" + oneMenu).addClass('nav-active');
		sub.slideDown(0, function() {
			mainContentHeightAdjust();
		});
	}
	function mainContentHeightAdjust() {
		var docHeight = jQuery(document).height();
		if (docHeight > jQuery('.main-content').height())
			jQuery('.main-content').height(docHeight);
	}
	function visibleSubMenuClose() {
		jQuery('.menu-list').each(function() {
			var t = jQuery(this);
			if (t.hasClass('nav-active')) {
				t.find('> ul').slideUp(200, function() {
					t.removeClass('nav-active');
				});
			}
		});
	}
	function modifyInternalWorker() {
		if (checkPassword($('#iworkerPassword').val())) {

			$.post("${ctxPath}/internalWorker/modify", $("#modifyForm")
					.serialize(), function(data) {
				if (data) {
					$("#myModal").modal('hide')
					$('#modifyForm')[0].reset();
					logoutAlert();
				} else {
					$('#modifyForm')[0].reset();
				}
			});
		} else {
			toastr.error("您的密码不符合要求，密码由6到20位数字和字母组成。");
		}

	}
	function logoutIntenalWorker() {
		$.get("${ctxPath}/internalWorker/logout", function(data) {
			window.location.href = "${ctxPath}/login.html";
		});
	}
	function fun() {
		if (i == 0) {
			logoutIntenalWorker();
			clearInterval(intervalid);
		}
		toastr.warning('修改密码成功，请牢记您修改的密码，您将在' + i + '秒后退出');
		i--;
	}
	var i = 5;
	//操作失败之后提示
	function logoutAlert() {
		var intervalid;
		intervalid = setInterval("fun()", 1000);
	}
	function checkPassword(password) {
		var reg = /^[A-Za-z]+[0-9]+[A-Za-z0-9]*|[0-9]+[A-Za-z]+[A-Za-z0-9]*$/g;
		if (!reg.test(password)) {
			return false;
		}
		return true;
	}
	$(function() {
		//初始化toastr
		toastr.options = {
			"closeButton" : false,
			"debug" : false,
			"positionClass" : "toast-top-center",
			"showDuration" : "300",
			"hideDuration" : "1000",
			"timeOut" : "5000",
			"extendedTimeOut" : "1000",
			"showEasing" : "swing",
			"hideEasing" : "linear",
			"showMethod" : "fadeIn",
			"hideMethod" : "fadeOut"
		};
		$('#myModal').on('hide.bs.modal', function() {
			$('#submitModifyFormButton').attr('disabled', 'disabled');
			$('#modifyForm')[0].reset();
		});
		/* 		if ($.browser.msie) {
		 document.getElementById('rePutPassword').attachEvent(
		 "onpropertychange", inputChange);
		 document.getElementById('iworkerPassword').attachEvent(
		 "onpropertychange", inputChange);
		 } else {
		 document.getElementById('rePutPassword').addEventListener("input",
		 inputChange, false);
		 document.getElementById('iworkerPassword').addEventListener(
		 "input", inputChange, false);
		 }
		 */
	});
	/**需要实际进行的操作**/
	function inputChange() {
		if ($('#iworkerPassword').val() == $('#rePutPassword').val()) {
			$('#submitModifyFormButton').removeAttr('disabled');
		} else {
			$('#submitModifyFormButton').attr('disabled', 'disabled');
		}
	}
</script>
